<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateEpisodesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('episodes', function (Blueprint $table) {
            $table->increments('id');
            $table->string('raw_name')->unique();
            $table->string('provider');
            $table->string('url_provider');

            $table->smallInteger('season');
            $table->smallInteger('episode');
            $table->integer('show_id')->unsigned();
            $table->foreign('show_id')->references('id')->on('shows')->onDelete('cascade');

            $table->string('size');
            $table->string('quality');
            $table->boolean('is_auth');
            $table->string('url_tvmaze');
            $table->string('url_douban');

            $table->string('url_torrent');
            $table->string('url_magnet');
            $table->string('url_ed2k');
            $table->string('url_baidupan');
            $table->string('url_video');
            $table->string('url_other');

            $table->unsignedMediumInteger('like_count');
            $table->integer('movie_id')->unsigned();

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        schema::drop('episodes');
    }
}
